import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

const routes = [
  { path: "/", redirect: "/login" },

  { path: "/login", component: () => import("@/view/Login"),meta:{ title:'登陆'}},//登陆页面
  
  {
    path: '/home',
    component: () => import("@/view/Home"),
    redirect: '/wellcome',
    children: [
      { path: '/wellcome', component: () => import("@/view/Wellcome"),meta:{ title:'欢迎'}},//欢迎页面
      { path: '/PersonalManagement', component: () => import("@/view/Personal/PersonalManagement"),meta:{ title:'个人中心'} },//个人中心
      { path: '/editPassword', component: () => import("@/view/Personal/editPassword") },//修改密码
      { path: '/banner', component: () => import("@/view/shouye/banner") ,meta:{ title:'轮播图管理'}},//轮播图管理
      { path: '/category', component: () => import("@/view/shouye/category"),meta:{ title:'分类区管理'} },//分类区管理
      { path: '/recomened', component: () => import("@/view/shouye/recomened"),meta:{ title:'为您推荐'} },//为您推荐管理
      { path: '/Classifiedmanagement', component: () => import("@/view/Commodity/Classifiedmanagement"),meta:{ title:'分类管理'} },//分类管理
      { path: '/Brandmanagement', component: () => import("@/view/Commodity/Brandmanagement"),meta:{ title:'品牌管理'} },//品牌管理
      { path: '/Commoditymanagement', component: () => import("@/view/Commodity/Commoditymanagement"),meta:{ title:'商品管理'} },//商品管理
      { path: '/Singleproduct', component: () => import("@/view/Commodity/Singleproduct"),meta:{ title:'单品管理'} },//单品管理
      { path: '/article', component: () => import("@/view/shopping/article"),meta:{ title:'新闻管理'} },//新闻管理
      { path: '/test', component: () => import("@/view/shopping/test"),meta:{ title:'111'} },//111
      // { path: '/personnelManagement', component: () => import("@/view/PersonnelManagement/index"),meta:{ title:'人员管理'}},//人员管理
      // { path: '/personnelEdit', component: () => import("@/view/PersonnelManagement/PersonnelEdit"),meta:{ title:'信息编辑'}},//人员编辑
    ]
  }
]

const router = new VueRouter({
  mode: "history",
  routes,
});
router.beforeEach((to, from, next) => {
  /* 路由发生变化修改页面title */
  if (to.meta.title) {
    document.title = to.meta.title
  }
  next()
})

export default router;
